﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Business_Layer
{
    [Serializable]
    public class Picture : Component
    {
        public Picture(int xPos, int yPos, int width, int height, string text, Bitmap picture)
            : base(xPos, yPos, width, height, text)
        {
            colorBehaviour = new NotColorable();
            this.picture = picture;
            if (sx > ex)
            {
                int temp = this.sx;
                this.sx = this.ex;
                this.ex = temp;
            }

            if (sy > ey)
            {
                int temp = this.sy;
                this.sy = this.ey;
                this.ey = temp;
            }
        }

        /// <summary>
        /// Changes the pictures color.
        /// </summary>
        /// <param name="color"></param>
        public override void ChangeColor(Color color)
        {
            colorBehaviour.SetColor(color);
        }

        private Bitmap picture;

        /// <summary>
        /// Draw the picture on Graphics.
        /// </summary>
        /// <param name="g">Graphics object.</param>
        /// <returns></returns>
        public override Graphics Draw(Graphics g)
        {
           g.DrawImage(picture, sx,sy,ex - sx,ey - sy);      
            
            return g;
        }
    }
}
